package atest;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Atest {
	private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	public static void main(String[] args) {
		try {
			readFile("d:\\21111111sss11111111112.txt");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void readFile(String fileName) throws IOException, ParseException{  
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName),"utf-8"));
		String s = null;
		String this1 = "";
		String this2 = "";
		boolean firstout = true;
		boolean has = false;
		while((s = br.readLine())!=null){
			s = s.replaceAll("\\|", "").replaceAll("#", "");
//			System.out.println(s);
			String[] ss = s.split(" ");
			if(ss[0].equals("0") && firstout){
				if(ss.length < 4){
					this2="";
				}else{
					this2 = ss[3];
				}
				if(this1.length() > this2.length() || (this1.length() <= this2.length() && this2.indexOf(this1) == -1)){
					if(!has){
						System.out.println(ss[2]);
						has = true;
					}
				}
			}
			if(ss[0].equals("1")){
				this1 = ss[3];
				firstout = true;
				has = false;
			}
			if(format.parse(ss[1]).getTime() < format.parse("2014-04-01").getTime()){
				firstout = false;
			}
		}
	}
}
